package com.yvdedu.factory;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;

public class MySession {
	private static Configuration cfg;
	private static ServiceRegistry sr;
	private static SessionFactory sf;

	static {
		cfg = new Configuration().configure();
		sr = new StandardServiceRegistryBuilder().applySettings(
				cfg.getProperties()).build();
		sf = cfg.buildSessionFactory(sr);
	}

	public static Session getSession() {

		return sf.openSession();

	}
}
